<script>
export default {
  name: 'ChatLogVue',
  props: {
    speaker: {
      type: String,
      require: true,
      default: '404'
    },
    isRobot: {
      type: Boolean,
      require: true
    },
    message: {
      type: String,
      require: true,
      default: 'ERROR'
    }
  },
  computed: {
    userClass: function() {
      return (this.isRobot ? '' : 'user-back')
    },
    iconColor: function() {
      return (this.isRobot ? 'robot-icon-back' : 'user-icon-back')
    }
  }
}
</script>

<template>
  <div class="chat-container" :class="userClass">
    <div class="chat-left">
      <div class="chat-icon" :class="iconColor">
        <i v-if="!isRobot" class="el-icon-user" />
        <i v-else class="el-icon-cpu" />
      </div>
    </div>
    <div class="chat-content">
      <div class="chat-head">{{ speaker }}</div>
      <div class="chat-main">{{ message }}</div>
    </div>
  </div>
</template>

<style scoped lang="scss">
.chat-container{
  display: flex;
  margin-bottom: 5px;
}
.chat-icon{
  margin: 5px;
  padding: 3.6px 4px;
  border-radius: 40%;
}
.user-icon-back{
  background-color: lightcoral;
}
.robot-icon-back{
  background-color: moccasin;
}
.chat-head{
  margin: 5px 5px 5px 0;
  font-size: 20px;
  font-weight: bold;
}
.chat-main{
  padding-bottom: 10px;
  margin-right: 1cap;
  line-height: 1.75;
}
.user-back{
  background-color: #f4f4f5;
}
</style>
